
import 'package:flutter/cupertino.dart';

class TextUtils {
  static Size boundingTextSize(String text, TextStyle style,  {int maxLines = 2^31, double maxWidth = double.infinity}) {
    if (text.isEmpty) {
      return Size.zero;
    }
    final TextPainter textPainter = TextPainter(
        textDirection: TextDirection.ltr,
        text: TextSpan(text: text, style: style), maxLines: maxLines)
      ..layout(maxWidth: maxWidth);
    return textPainter.size;
  }

  static Size getTextSize(String text, double maxWidth, double fontSize) {
    TextStyle style = TextStyle(
      fontSize: fontSize,
    );
    return TextUtils.boundingTextSize(text, style,
        maxWidth: maxWidth);
  }

  static bool isNotNull(String? text) {
    if (text == null) {
      return false;
    }

    return text.isNotEmpty;
  }
}